www.gusucode.com > 落叶冰点万能企业网站内容管理系统 V9.1 > 落叶冰点万能企业网站内容管理系统 V9.1\code\inc\ND_model_do_upfile.asp

    

<%Server.ScriptTimeOut=5000%>


<%

dir_set="../"


%>




<!--#include file=conn.asp-->

<!--#include FILE="upload_5xsoft.asp"-->

<!--#include file=jpeg_draw.asp-->


<html>
<head>
<title>文件上传</title>
</head>
<body>

<%


'**************************************************************
' 新动软网站管理系统
' 官方网站: http://www.aspcpu.com
' 系统作者: 阮丁远(网名:天下程序)
' Copyright 新动软网站管理系统 版权所有
'**************************************************************


%>

<%








Function CreatePath(fromPath)
	Dim objFSO, uploadpath
	uploadpath = Year(Now) & "-" & Month(Now) '以年月创建上传文件夹,格式:2007-8
	uploadpath = Replace(uploadpath, ".", "_")
	On Error Resume Next
	Set objFSO =Server.CreateObject(fssoo_nd_var_str_x_customx)
	If objFSO.FolderExists(Server.MapPath(fromPath & uploadpath)) = False Then
		objFSO.CreateFolder Server.MapPath(fromPath & uploadpath)
	End If
	If Err.Number = 0 Then
		CreatePath = uploadpath & "/"
	Else
		CreatePath = ""
	End If
	Set objFSO = Nothing
End Function





if session("D_u_AllowFilesizea")="" then
if request.cookies("D_u_AllowFilesizea")="" then
D_u_AllowFilesizea=""
else
D_u_AllowFilesizea=request.cookies("D_u_AllowFilesizea")
end if
else
D_u_AllowFilesizea=session("D_u_AllowFilesizea")
end if


if session("D_u_AllowFileExta")="" then
if request.cookies("D_u_AllowFileExta")="" then
D_u_AllowFileExta=""
else
D_u_AllowFileExta=request.cookies("D_u_AllowFileExta")
end if
else
D_u_AllowFileExta=session("D_u_AllowFileExta")
end if





if session("D_u_xhidden")="" then
if request.cookies("D_u_xhidden")="" then
D_u_xhidden=""
else
D_u_xhidden=request.cookies("D_u_xhidden")
end if
else
D_u_xhidden=session("D_u_xhidden")
end if






if D_u_AllowFilesizea="" then
unlod=1
else
unlod=0
end if





if unlod=0 then




dim upload,file,formName,formPath,iCount
set upload=new upload_5xsoft ''建立上传对象



	Function RelativePath2RootPath(url)
		Dim sTempUrl
		sTempUrl = url
		If Left(sTempUrl, 1) = "/" Then
			RelativePath2RootPath = sTempUrl
			Exit Function
		End If

		Dim m_strPath
		m_strPath = Request.ServerVariables("SCRIPT_NAME")
		m_strPath = Left(m_strPath, InStrRev(m_strPath, "/") - 1)
		Do While Left(sTempUrl, 3) = "../"
			sTempUrl = Mid(sTempUrl, 4)
			m_strPath = Left(m_strPath, InStrRev(m_strPath, "/") - 1)
		Loop
		RelativePath2RootPath = m_strPath & "/" & sTempUrl
	End Function



 formPath=upload.form("filepath")
 ''在目录后加(/)
 if right(formPath,1)<>"/" then formPath=formPath&"/" 



iCount=0




randomize  
ranNum=int(999*rnd)  
filename=year(now)&month(now)&day(now)&hour(now)&minute(now)&second(now)&ranNum


sUploadDir="../uploadfile/adminModelUpload/"
        

	strUploadDir = CreatePath(sUploadDir)
	sUploadDir = sUploadDir & strUploadDir
        formPath=sUploadDir

err1=0
for each formName in upload.objFile ''列出所有上传了的文件
 set file=upload.file(formName)  ''生成一个文件对象


if file.FileSize>D_u_AllowFilesizea then 


response.write  "文件太大,上传失败! <a href=ND_model_upfile.asp>重新上传</a><script>alert('文件太大,上传失败!');</script>"
err1=1

end if


eee1=File.FileName
 
extnm=mid(eee1,inStrRev(eee1,".")+1,len(eee1)-inStrRev(eee1,".")) 

okkk=0
ssss111=split(D_u_AllowFileExta,"|")
for iyy=0 to ubound(ssss111)
ssss1112=ssss111(iyy)
if lcase(trim(cstr(ssss1112)))=lcase(trim(cstr(extnm))) then 
okkk=1
exit for
end if


'过滤asp文件等
if lcase(trim(cstr(extnm)))="asp" or lcase(trim(cstr(extnm)))="asa" or lcase(trim(cstr(extnm)))="aspx" or lcase(trim(cstr(extnm)))="php" or lcase(trim(cstr(extnm)))="jsp" or lcase(trim(cstr(extnm)))="cgi" then
okkk=0
exit for
end if

next




if okkk=0 then
err1=1
response.write  "文件类型不正确,上传失败! <a href=ND_model_upfile.asp>重新上传</a><script>alert('文件类型不正确,上传失败!');</script>"


end if







 if file.FileSize>0  and err1=0 then         ''如果 FileSize > 0 说明有文件数据
  file.SaveAs Server.mappath(formPath&filename&"."&extnm)   ''保存文件

call do_shuiying(formPath&filename&"."&extnm)


 ' response.write file.FilePath&filename&" ("&file.FileSize&") => "&formPath&File.FileName&" 上传成功!<br>"



ttttppppt=RelativePath2RootPath(formPath&filename&"."&extnm)

response.write  File.FileName&" 上传成功! <script language=javascript>parent.document.getElementById("""&D_u_xhidden&""").value="""&ttttppppt&""";try{parent.document.getElementById("""&"nd_pre_uploada_pic_x_"&D_u_xhidden&""").src="""&ttttppppt&""";}catch(e){}</script>"



 end if
 set file=nothing
next

set upload=nothing  ''删除此对象



end if

%>
</body>
</html>